﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Things.OrderPlan.Models;

namespace Things.OrderPlan
{
    public class PlanningGoodsSearcher : IPlanningGoodsSearcher
    {
        public Goods Find(Guid goodsId)
        {
            using (Models.ModelsContainer container = new ModelsContainer())
            {
                string sql = "select g.* from Things_Goods as g";
                return container.ExecuteStoreQuery<Goods>(sql, null).Where<Goods>(p=>p.GoodsID==goodsId).FirstOrDefault<Goods>();
            }
        }

        public List<Goods> FindAll()
        {
            using (Models.ModelsContainer container = new ModelsContainer())
            {
                string sql = "select g.* from Things_Goods as g where g.GoodsID in (select goodsid from SaleSetSet)";
                return container.ExecuteStoreQuery<Goods>(sql, null).ToList<Goods>();
            }
        }
    }
}
